
package cn.cloud.all.security.oauth2.config.annotation;

import cn.cloud.all.security.oauth2.provider.ClientDetails;
import cn.cloud.all.security.oauth2.provider.ClientDetailsService;
import cn.cloud.all.security.oauth2.provider.client.InMemoryClientDetailsService;

import java.util.HashMap;
import java.util.Map;

public class InMemoryClientDetailsServiceBuilder extends ClientDetailsServiceBuilder<InMemoryClientDetailsServiceBuilder> {

    private Map<String, ClientDetails> clientDetails = new HashMap<String, ClientDetails>();

    @Override
    protected void addClient(String clientId, ClientDetails value) {
        clientDetails.put(clientId, value);
    }

    @Override
    protected ClientDetailsService performBuild() {
        InMemoryClientDetailsService clientDetailsService = new InMemoryClientDetailsService();
        clientDetailsService.setClientDetailsStore(clientDetails);
        return clientDetailsService;
    }
}
